import router from "@/router";
import axios from "axios";
import ElementUI from "element-ui";

// //全局配置axios
const request = axios.create({
    baseURL: 'http://localhost:9090',
    timeout: 5000
})
// //请求拦截
axios.interceptors.request.use(config => {
    // config.headers['Content-Type'] = 'application/json;charset=utf-8'

    // let user = localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : null
    // this.token = user.data.token
    // //如果本地存储有token（代表已登录），请求都携带该token发送请求  
    // if (user) {
    //     config.headers['token'] = user.token; //设置请求头
    // }
    return config;
}, error => {
    Promise.reject(error)
})

//响应拦截
axios.interceptors.response.use(res => {
    return res.data
}
)

export default axios;